= Ruby backend

The rest of this documentation covers the back-end internal API used to drive Alex's UQ Web Timetabler. The system consists of a timetabling library (covered in the Timetable module) and a WEBrick-based web server (in the TTServer module). Data storage is done in Marshalled .dat files, and communication with the UI is via JSON.

The code is compiled to Java bytecode using the JRuby system, and then run on the Sun JVM in the current production environment. This is done for performance and concurrency; the JVM supports native threads and far stronger arithmetic performance, useful in the optimisation routines.

== Course terminology

A typical UQ course consists of a bunch of "series" -- a lecture series, tutorial series, contact series, practical series etc. Each of these series contains "groups" -- lecture group 1 is abbreviated "L1", tutorial group 5, "T5" etc. Groups then have "sessions" -- actual timetabled events associated with the group.

== What this API does

* Downloads timetable data from mySI-net
* Parses it into objects
* Looks up information to respond to queries using those objects
* Respresents that information in JSON and iCal formats

Timetable optimisation (according to weighted rules) is enabled by the Timetable::Optimisation module. It operates by brute force and is thus fairly slow. There is also some experimental support for using genetic algorithms to breed a timetable containing desired characteristics (see the Timetable::Genetics module).

== Example

Let's say we want to download and index the course 'COUR1234' from mySI-net.

  cf = Timetable::CourseFactory.new 'user', 'pass', ['COUR1234']
  cf.fetch
  cf.parse

The course is now indexed and represented in memory. To save to disk, all we have to do is

  c = Timetable::Course.find('COUR1234')
  c.dump

This will save the course to disk and update the index file appropriately. This is all the TTServer module does in reality -- load courses in this manner, find them, and grab information about them. For example, we could get the list of timetable series available in our course

  c.series.collect { |s| s.series } # --> ['L', 'T', 'C'...]

And many more bits of information by way of the Timetable::Course, Timetable::Series, Timetable::Group and Timetable::Session objects.